package com.block.risk.model;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.*;

public class ReportUtil {

        static HashMap<String, String> applyReportDetail = new HashMap<>();
        static HashMap<String, String> behaviorReportDetail = new HashMap<>();
        static HashMap<String, String> currentReportDetail = new HashMap<>();


        public static List<Map<String, String>> getApplyReportDetailMap(JSONObject resultDetail){
                JSONObject apply_report_detail = resultDetail.getJSONObject("apply_report_detail");

                List<Map<String, String>> resultList = new ArrayList<>();
                if (ObjectUtil.isEmpty(apply_report_detail)){
                        return resultList;
                }

                Set<String> keySet = apply_report_detail.keySet();

                List<String> keyList = JSON.parseArray(JSON.toJSONString(keySet), String.class);
                Collections.sort(keyList);

                for (String key : keyList) {

                        Map<String, String> resultMap = new HashMap<>();
                        String value = apply_report_detail.getString(key);
                        String name = applyReportDetail.get(key);
                        resultMap.put("name", name);
                        resultMap.put("value", value);

                        resultList.add(resultMap);
                }
                return resultList;
        }

        public static List<Map<String, String>> getBehaviorReportDetailMap(JSONObject resultDetail){
                JSONObject behavior_report_detail = resultDetail.getJSONObject("behavior_report_detail");

                List<Map<String, String>> resultList = new ArrayList<>();
                if (ObjectUtil.isEmpty(behavior_report_detail)){
                        return resultList;
                }

                Set<String> keySet = behavior_report_detail.keySet();

                List<String> keyList = JSON.parseArray(JSON.toJSONString(keySet), String.class);
                Collections.sort(keyList);

                for (String key : keyList) {

                        Map<String, String> resultMap = new HashMap<>();
                        String value = behavior_report_detail.getString(key);
                        String name = behaviorReportDetail.get(key);
                        resultMap.put("name", name);
                        resultMap.put("value", value);

                        resultList.add(resultMap);
                }
                return resultList;
        }

        public static List<Map<String, String>> getCurrentReportDetailMap(JSONObject resultDetail){
                JSONObject current_report_detail = resultDetail.getJSONObject("current_report_detail");

                List<Map<String, String>> resultList = new ArrayList<>();
                if (ObjectUtil.isEmpty(current_report_detail)){
                        return resultList;
                }

                Set<String> keySet = current_report_detail.keySet();
                List<String> keyList = JSON.parseArray(JSON.toJSONString(keySet), String.class);
                Collections.sort(keyList);

                for (String key : keyList) {

                        Map<String, String> resultMap = new HashMap<>();
                        String value = current_report_detail.getString(key);
                        String name = currentReportDetail.get(key);
                        resultMap.put("name", name);
                        resultMap.put("value", value);

                        resultList.add(resultMap);
                }
                return resultList;
        }



        static {
        applyReportDetail.put("A22160001", "申请准入分");
        applyReportDetail.put("A22160002", "申请准入置信度");
        applyReportDetail.put("A22160003", "申请命中机构数");
        applyReportDetail.put("A22160004", "申请命中消金类机构数");
        applyReportDetail.put("A22160005", "申请命中网络贷款类机构数");
        applyReportDetail.put("A22160006", "机构总查询次数");
        applyReportDetail.put("A22160007", "最近一次查询时间");
        applyReportDetail.put("A22160008", "近1个月机构总查询笔数");
        applyReportDetail.put("A22160009", "近3个月机构总查询笔数");
        applyReportDetail.put("A22160010", "近6个月机构总查询笔数");

        behaviorReportDetail.put("B22170001", "贷款行为分");
        behaviorReportDetail.put("B22170002", "近1个月贷款笔数");
        behaviorReportDetail.put("B22170003", "近3个月贷款笔数");
        behaviorReportDetail.put("B22170004", "近6个月贷款笔数");
        behaviorReportDetail.put("B22170005", "近12个月贷款笔数");
        behaviorReportDetail.put("B22170006", "近24个月贷款笔数");
        behaviorReportDetail.put("B22170007", "近1个月贷款总金额");
        behaviorReportDetail.put("B22170008", "近3个月贷款总金额");
        behaviorReportDetail.put("B22170009", "近6个月贷款总金额");
        behaviorReportDetail.put("B22170010", "近12个月贷款总金额");
        behaviorReportDetail.put("B22170011", "近24个月贷款总金额");
        behaviorReportDetail.put("B22170012", "近12个月贷款金额在1k及以下的笔数");
        behaviorReportDetail.put("B22170013", "近12个月贷款金额在1k-3k及以下的笔数");
        behaviorReportDetail.put("B22170014", "近12个月贷款金额在3k-10k及以下的笔数");
        behaviorReportDetail.put("B22170015", "近12个月贷款金额在1w及上的笔数");
        behaviorReportDetail.put("B22170016", "近1个月贷款机构数");
        behaviorReportDetail.put("B22170017", "近3个月贷款机构数");
        behaviorReportDetail.put("B22170018", "近6个月贷款机构数");
        behaviorReportDetail.put("B22170019", "近12个月贷款机构数");
        behaviorReportDetail.put("B22170020", "近24个月贷款机构数");
        behaviorReportDetail.put("B22170021", "近12个月消金类贷款机构数");
        behaviorReportDetail.put("B22170022", "近24个月消金类贷款机构数");
        behaviorReportDetail.put("B22170023", "近12个月网贷类贷款机构数");
        behaviorReportDetail.put("B22170024", "近24个月网贷类贷款机构数");
        behaviorReportDetail.put("B22170025", "近6个月M0+逾期贷款笔数");
        behaviorReportDetail.put("B22170026", "近12个月M0+逾期贷款笔数");
        behaviorReportDetail.put("B22170027", "近24个月M0+逾期贷款笔数");
        behaviorReportDetail.put("B22170028", "近6个月M1+逾期贷款笔数");
        behaviorReportDetail.put("B22170029", "近12个月M1+逾期贷款笔数");
        behaviorReportDetail.put("B22170030", "近24个月M1+逾期贷款笔数");
        behaviorReportDetail.put("B22170031", "近6个月累计逾期金额");
        behaviorReportDetail.put("B22170032", "近12个月累计逾期金额");
        behaviorReportDetail.put("B22170033", "近24个月累计逾期金额");
        behaviorReportDetail.put("B22170034", "正常还款订单数占贷款总订单数比例");
        behaviorReportDetail.put("B22170035", "近1个月失败扣款笔数");
        behaviorReportDetail.put("B22170036", "近3个月失败扣款笔数");
        behaviorReportDetail.put("B22170037", "近6个月失败扣款笔数");
        behaviorReportDetail.put("B22170038", "近12个月失败扣款笔数");
        behaviorReportDetail.put("B22170039", "近24个月失败扣款笔数");
        behaviorReportDetail.put("B22170040", "近1个月履约贷款总金额");
        behaviorReportDetail.put("B22170041", "近3个月履约贷款总金额");
        behaviorReportDetail.put("B22170042", "近6个月履约贷款总金额");
        behaviorReportDetail.put("B22170043", "近12个月履约贷款总金额");
        behaviorReportDetail.put("B22170044", "近24个月履约贷款总金额");
        behaviorReportDetail.put("B22170045", "近1个月履约贷款次数");
        behaviorReportDetail.put("B22170046", "近3个月履约贷款次数");
        behaviorReportDetail.put("B22170047", "近6个月履约贷款次数");
        behaviorReportDetail.put("B22170048", "近12个月履约贷款次数");
        behaviorReportDetail.put("B22170049", "近24个月履约贷款次数");
        behaviorReportDetail.put("B22170050", "最近一次履约距今天数");
        behaviorReportDetail.put("B22170051", "贷款行为置信度");
        behaviorReportDetail.put("B22170052", "贷款已结清订单数");
        behaviorReportDetail.put("B22170053", "信用贷款时长");
        behaviorReportDetail.put("B22170054", "最近一次贷款放款时间");

        currentReportDetail.put("C22180001", "网贷授信额度");
        currentReportDetail.put("C22180002", "网贷额度置信度");
        currentReportDetail.put("C22180003", "网络贷款类机构数");
        currentReportDetail.put("C22180004", "网络贷款类产品数");
        currentReportDetail.put("C22180005", "网络贷款机构最大授信额度");
        currentReportDetail.put("C22180006", "网络贷款机构平均授信额度");
        currentReportDetail.put("C22180007", "消金贷款类机构数");
        currentReportDetail.put("C22180008", "消金贷款类产品数");
        currentReportDetail.put("C22180009", "消金贷款类机构最大授信额度");
        currentReportDetail.put("C22180010", "消金贷款类机构平均授信额度");
        currentReportDetail.put("C22180011", "消金建议授信额度");
        currentReportDetail.put("C22180012", "消金额度置信度");

    }





}
